//
//  JWTBaseNavigationViewController.m
//  JWT
//
//  Created by Apple on 2017/1/1.
//  Copyright © 2017年 com.jwtsoft. All rights reserved.
//

#import "JWTBaseNavigationViewController.h"

@interface JWTBaseNavigationViewController ()

@end

@implementation JWTBaseNavigationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

// 是否可右滑返回
- (void)navigationCanDragBack:(BOOL)bCanDragBack
{
    if (iOS7)
    {
        self.interactivePopGestureRecognizer.enabled = bCanDragBack;
    }
    else{}
}


-(void) updateTheme
{
    if(iOS7)
    {
        self.navigationBar.barTintColor = RGB(57, 81, 146);;  //RGB(57, 81, 146);
        self.navigationBar.tintColor    = RGB(57, 81, 146);  //(57, 81, 146);
        
        //NSShadow *shadow = [[NSShadow alloc] init];
        //shadow.shadowColor  =  [UIColor colorWithRed:250.0 green:250.0 blue:250.0 alpha:0.8];
        //shadow.shadowOffset = CGSizeMake(0, 1);
        
        [self.navigationBar
         setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
                                  RGB(60, 55, 82), NSForegroundColorAttributeName,
                                  nil, NSShadowAttributeName,
                                  [UIFont boldSystemFontOfSize:18], NSFontAttributeName, nil]];
        
    }
    else
    {
        //        self.navigationBar.tintColor = RGB0xFFFFFF(0x395292);
        self.navigationBar.tintColor = RGB(57, 81, 146);
    }
    
    /*
     CGRect rect = CGRectMake(0, 0, 200, 44);
     UILabel *label = [[UILabel alloc] initWithFrame:rect];
     label.backgroundColor = [UIColor clearColor];
     label.text = @"导航标题没有得到的";
     label.textColor = [UIColor whiteColor];
     label.adjustsFontSizeToFitWidth=YES;
     self.navigationItem.titleView = label;*/
    
}



/**根据类名 在导航中找到 该类视图，找到后直接 popToViewController*/
-(void) popToTheViewControllor:(NSString *)classString withAnimation:(BOOL)animation
{
    //删除导航中 不需要的 回退
    NSMutableArray *vcarrays    = [NSMutableArray arrayWithArray:self.viewControllers];
    UIViewController *needbackVC;
    for (NSInteger i=0;i<vcarrays.count;i++)
    {
        UIViewController *nvc = vcarrays[i];
        if([nvc isKindOfClass:NSClassFromString(classString)])
        {
            needbackVC = nvc;
            break;
        }
    }
    if(needbackVC)
        [self popToViewController:needbackVC animated:animation];
    else
        [self popToRootViewControllerAnimated:animation];
}





@end
